
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
  <style>
     .checkbox-inline input[type=checkbox],.radio-inline input[type=radio] {
           margin-top: 4px;
      }
  </style>
</head>

<body style="color:#333;padding:3px;">
    <!-- 标题 -->
      <div class="page-heade">
       <h2 class="title_color text-center">{if condition="$gid eq 0"}添加{else/}修改{/if}供应商</h2>
    </div>
    <!-- 标题 -->
    <div>
    <form  id="f1"  class="form-inline">
    <input type="hidden" value="{$gid}" name="gid"/>
      <table class="row-margin-top tab-content table-bordered table text-left" border="1">
          <tr>
            <td style="min-width: 140px" class="text-right"><label for="" class="form-label">供应商编号：</label></td>
            <td><input type="text" class="form-control" name="no" {if condition="$gid neq 0"} value="{$gys.no}" readonly {/if}><span class="colorRed">(温馨说明：如果不填写供应商编号，系统将自动分配一个编号。)</span></td>
             <td style="min-width: 140px" class="text-right"><label for="" class="form-label">供应商简称：<span class="colorRed">*</span>：</label></td>
            <td colspan="3"><input type="text" class="form-control" name="gys_jian" {if condition="$gid neq 0"} value="{$gys.gys_jian}" {/if}></td>
           
             </tr>
             <tr>
                 <td style="min-width: 140px" class="text-right"><label for="" class="form-label">供应商全称<span class="colorRed">*</span>：</label></td>
            <td colspan="5"><input type="text" class="form-control" name="gys_name" {if condition="$gid neq 0"} value="{$gys.gys_name}" {/if}></td>
             </tr>
              <tr>
                 <td style="min-width: 140px" class="text-right"><label for="" class="form-label">供应商类别<span class="colorRed">*</span>：</label></td>
            <td colspan="5">
            	{if condition="$gid eq 0"}
               {volist name="gytype" id="vo"}
					<label class="checkbox-inline">
                    	<input type="checkbox" value="{$vo.id}" name="type_ids[]">{$vo.title}
              		</label>
               {/volist}
               {else/}
					 {volist name="gytype" id="vo"}
					<label class="checkbox-inline">
                    	<input type="checkbox" value="{$vo.id}" name="type_ids[]" {if condition="$vo.ck eq 1"}checked{/if}>{$vo.title}
              		</label>
               		{/volist}
               {/if}
               
            </td>
             </tr>
             <tr>

               <td style="min-width: 140px" class="text-right"><label for="" class="form-label">税号<span class="colorRed">*</span>：</label></td>
            <td><input type="text" class="form-control" name="tax_id" {if condition="$gid neq 0"} value="{$gys.tax_id}" {/if}></td>
             <td style="min-width: 140px" class="text-right"><label for="" class="form-label">开户银行<span class="colorRed">*</span>：</label></td>
            <td ><input type="text" class="form-control" name="bank" {if condition="$gid neq 0"} value="{$gys.bank}" {/if}></td>
              <td style="min-width: 140px" class="text-right"><label for="" class="form-label">开户银行号<span class="colorRed">*</span>：</label></td>
            <td ><input type="text" class="form-control" name="bank_no" {if condition="$gid neq 0"} value="{$gys.bank_no}" {/if}></td>
             </tr>
               <tr>

               <td style="min-width: 140px" class="text-right"><label for="" class="form-label">是否是一般纳税人<span class="colorRed">*</span>：</label></td>
            <td>
            	{if condition="$gid neq 0"}
                 <label class="radio-inline">
                      <input type="radio" name="is_yiban" value="1" {if condition="$gys.is_yiban eq 1"} checked {/if}>是
                </label>
                 <label class="radio-inline">
                      <input type="radio" name="is_yiban" value="0" {if condition="$gys.is_yiban eq 0"} checked {/if}>否
                </label>
                {else/}
                  <label class="radio-inline">
                      <input type="radio" name="is_yiban" checked value="1">是
                </label>
                 <label class="radio-inline">
                      <input type="radio" name="is_yiban" value="0">否
                </label>
                {/if}

            </td>
             <td style="min-width: 140px" class="text-right"><label for="" class="form-label">供应商电话<span class="colorRed">*</span>：</label></td>
            <td ><input type="text" class="form-control" name="phone"  {if condition="$gid neq 0"} value="{$gys.phone}" {/if}></td>
              <td style="min-width: 140px" class="text-right"><label for="" class="form-label">邮箱：</label></td>
            <td ><input type="text" class="form-control" name="email"  {if condition="$gid neq 0"} value="{$gys.email}" {/if}></td>
             </tr>
               <tr>
                 <td style="min-width: 140px" class="text-right"><label for="" class="form-label">公司注册地址<span class="colorRed">*</span>：</label></td>
            <td colspan="5"><input type="text" style="width:80%" class="form-control" name="sign_address"  {if condition="$gid neq 0"} value="{$gys.sign_address}" {/if}></td>
             </tr>
               <tr>

               <td style="min-width: 140px" class="text-right"><label for="" class="form-label">联系人姓名<span class="colorRed">*</span>：</label></td>
            <td><input type="text" class="form-control" name="contact"  {if condition="$gid neq 0"} value="{$gys.contact}" {/if}></td>
             <td style="min-width: 140px" class="text-right"><label for="" class="form-label">联系人电话<span class="colorRed">*</span>：</label></td>
            <td ><input type="text" class="form-control" name="tel"  {if condition="$gid neq 0"} value="{$gys.tel}" {/if}></td>
              <td style="min-width: 140px" class="text-right"><label for="" class="form-label">公司传真：</label></td>
            <td ><input type="text" class="form-control" name="fax"  {if condition="$gid neq 0"} value="{$gys.fax}" {/if}></td>
             </tr>
              <tr>
                 <td style="min-width: 140px" class="text-right"><label for="" class="form-label">邮寄地址<span class="colorRed">*</span>：</label></td>
            <td colspan="5"><input type="text" class="form-control" name="address" style="width:80%"  {if condition="$gid neq 0"} value="{$gys.address}" {/if}></td>
             </tr>
              <tr>

               <td style="min-width: 140px" class="text-right"><label for="" class="form-label">收件人<span class="colorRed">*</span>：</label></td>
            <td><input type="text" class="form-control" name="shoujian"  {if condition="$gid neq 0"} value="{$gys.shoujian}" {/if}></td>
             <td style="min-width: 140px" class="text-right"><label for="" class="form-label">收件人电话<span class="colorRed">*</span>：</label></td>
            <td colspan="3"><input type="text" class="form-control" name="shoujian_tel"  {if condition="$gid neq 0"} value="{$gys.shoujian_tel}" {/if}></td>
             </tr>
             <tr>
            <td style="min-width: 140px" class="text-right" rowspan="2"><label for="" class="form-label">备注：</label></td>
            <td colspan="5">
                <textarea name="remark" id="" class="form-control" rows="2" style="user-select:none;width: 70%">{if condition="$gid neq 0"}{$gys.remark}{/if}</textarea><span style="vertical-align: bottom;">500</span>
            </td>
             </tr>
      </table>
     <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                   {volist name="fujian" id="fo"}
                        <h4>{$fo.file_name}</h4>
                   {/volist}
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default" type="button">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach" {if condition="$gid neq 0"}{if condition="$gys.fujian neq ''"} value="{$gys.fujian}"{/if} {/if} >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
       <div class="text-center">
            <button class="btn btn-warning" id="baocun" type="button">保存</button>
            <button class="btn btn-success" type="button" style="margin-left: 20px" id="back">返回</button>
      </div>
</form>
    </div>
     <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
      <script src="__STATIC__/layout/js/common.js"></script>

      <script>
      $("#back").click(function(){
      	location.href='{:url("Gys/manage")}';
      })
      	//提交验证
    //名称正则
 	var regex=/^[a-zA-Z0-9_\-()（）\u4e00-\u9fa5]{1,30}$/;
 	//编号
	var regex_no=/^[a-zA-Z0-9_\-]{1,20}$/;
	var regex_mobile=/^1[3458]\d{9}$/; 
	var regex_phone=/^\d{3,5}\-\d{7,8}$/;
	$("#baocun").click(function(){
		var msg="";
		if(!regex.test($("input[name='gys_jian']").val())){
			msg="简称由字母数字下划线和中文组成";
		}else if(!regex.test($("input[name='gys_name']").val())){
			msg="全称由字母数字下划线和中文组成";
		}else if($("input[name='tax_id']").val()==""){
			msg="税号不能为空";
		}else if($("input[name='bank']").val()==""){
			msg="开户银行不能为空";
		}else if($("input[name='bank_no']").val()==""){
			msg="银行帐号不能为空";
		}else if(!(regex_phone.test($("input[name='phone']").val())||regex_mobile.test($("input[name='phone']").val()))){
			msg="供应商电话错误，请输如正确固话或手机格式,固话格式021-88888888";
		}else if($("input[name='sign_address']").val()==""){
			msg="公司注册地址不能为空";
		}else if($("input[name='contact']").val()==""){
			msg="联系人姓名不能为空";
		}else if(!(regex_phone.test($("input[name='tel']").val())||regex_mobile.test($("input[name='tel']").val()))){
			msg="联系人电话错误，请输如正确固话或手机格式,固话格式021-88888888";
		}else if($("input[name='sign_address']").val()==""){
			msg="邮寄地址不能为空";
		}else if($("input[name='shoujian']").val()==""){
			msg="收件人不能为空";
		}else if(!(regex_phone.test($("input[name='shoujian_tel']").val())||regex_mobile.test($("input[name='shoujian_tel']").val()))){
			msg="收件人电话错误，请输如正确固话或手机格式,固话格式021-88888888";
		}

		if(msg==""){
			$.ajax({
               			cache: true,
               			type: "POST",
                		url:"{:url('Gys/addchuli')}",
                		data:$('#f1').serialize(),// 你的formid
                		async: false,
		                error: function(request) {
		                    alert("Connection error");
		                },
		                success: function(data) {
		                	//alert(data);
		                	var re=JSON.parse(data);
		                	if(re["state"]==1){
		                		swal({title: "完成", text: "操作已成功", type: "success"},function(){location.href='{:url("Gys/manage")}'});
		                	}else{
		                		swal({title: "错误", text: re["msg"], type: "warning"});
		                	}
				        }
		               
		            });
		}else{
			swal({title: "错误", text: msg, type: "warning"});
		}
	})
      </script>
      <!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
   <script>
   	 // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [{if condition="$gid neq 0"}{if condition="$gys.fujian neq ''"} value="{$gys.fujian}"{/if} {/if}];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });
  });
   </script>
</body>

</html>
